#ifndef QPAGEMANAGER_H
#define QPAGEMANAGER_H

#include <QObject>
#include <QMap>

class QAbstractHost;

class QPageManager : public QObject
{
    Q_OBJECT
public:
    explicit QPageManager(QObject *parent = 0);

    void    load(const QString &project_path);

    void    save(const QString& project_path);

    void    clear();

    QList<QAbstractHost*>   get_pages();
    QAbstractHost*          get_page(int index);
    QAbstractHost*          get_page(const QString& uuid);
    void                    insert_page(QAbstractHost* host,int index);
    void                    remove_page(QAbstractHost* host);
    QList<QAbstractHost*>   get_pages_by_type(const QString& type);
    
signals:
    void    insert_page_signal(QAbstractHost* host);
    void    remove_page_signal(QAbstractHost* host);
    void    host_name_changed(QAbstractHost* host);
protected:
    void    load_page(const QString &fileName);
protected slots:
    void    host_name_changed_slot(const QVariant &old_name,const QVariant& new_name);
protected:
    QList<QAbstractHost*>           m_page_list;
    QMap<QString,QAbstractHost*>    m_uuid_to_page;
    QString                         m_project_path;
};

#endif // QPAGEMANAGER_H
